// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  app: {
    baseURL: '/nuxt/',
    head: {
      title: '测试模板',
      charset: 'utf-8',
      viewport: 'width=device-width, initial-scale=1',
      meta: [
        { name: 'description', content: 'bytech' },
        { name: 'keywords', content: 'docs vue3' }
      ],
      link: [
        {
          rel: 'icon',
          type: 'image/svg+xml',
          href: '/nuxt/favicon.svg',
        },
        {
          rel: 'icon',
          type: 'image/x-icon',
          href: '/nuxt/favicon.ico',
        }
      ]
    },
  },
  devServer: {
    host: '0.0.0.0',
    port: 3128
  },
  css: ['~/assets/scss/main.scss'],
  compatibilityDate: '2024-11-01',
  devtools: { enabled: true },
  modules: ['@element-plus/nuxt'],
  runtimeConfig: {
    // 私有密钥仅在服务器端可用
    // Default to an empty string,
    // automatically set at runtime using process.env.NUXT_API_KEY
    apiSecret: '123456',
    // public 命名空间中定义的，在服务器端和客户端都可以普遍访问
    public: {
      // 声明这个位置要的字符串要使用环境变量HOST_ENV的值
      HOST_ENV: '{{HOST_ENV}}',
      apiBase: process.env.NUXT_PUBLIC_API_BASE || '/api'
    }
  },
  // 如果存在跨域
  nitro: {
    devProxy: {
      '/api_v2': {
        target: process.env.NUXT_PUBLIC_API_BASE,
        changeOrigin: true,
      }
    }
  },
  // https://sass-lang.com/documentation/breaking-changes/legacy-js-api/
  vite: {
    css: {
      preprocessorOptions: {
        scss: {
          silenceDeprecations: ['legacy-js-api']
        }
      }
    }
  }
})
